package com.kms.monitor;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @author <a href="mailto:zhangting@taobao.com">张挺</a>
 * @since 2010-3-26 10:11:16
 */
public class SystemEnvDemo {
    public static void main(String[] args) {
        System.out.println("current system environment variable:");
        Map<String,String> map = System.getenv();
        Set<Map.Entry<String,String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }

        System.out.println("---------------");
        System.out.println("current system properties:");
        Properties properties = System.getProperties();
        Set<Map.Entry<Object, Object>> set = properties.entrySet();
        for (Map.Entry<Object, Object> objectObjectEntry : set) {
            System.out.println(objectObjectEntry.getKey() + ":" + objectObjectEntry.getValue());
        }
        
        Runtime run = Runtime.getRuntime();
        long max = run.maxMemory();
        long total = run.totalMemory();
        long free = run.freeMemory();
        long usable = max - total + free;
        System.out.println("最大内存 =              " + max );
        System.out.println("已分配内存 =            " + total );
        System.out.println("已分配内存中的剩余空间     " + free );
        System.out.println("最大可用内存                              " + usable ); 
    }
}